//
//  main.m
//  HomeWork 03 - NSString NSArray NSMutableArray
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"
int main(int argc, const char * argv[]) {
    /** 1.截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
     2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
     3.实现图书管理系统(BookManager类)：
     使用数组管理所有书籍(Book类)。
     BookManager类属性数组可以添加、删除。
     可以从数组根据书名查找书籍，并修改书籍的价格。
     展示所有书籍清单（书名） */
    //1.
    NSString *str = @"20|https://www.baidu.com";
    NSArray *arr = [str componentsSeparatedByString:@"|"];
    NSString *str1 = arr[0];
    NSString *str2 = arr[1];
    NSLog(@"前面的字符串是:%@ 后面的字符串是:%@",str1,str2);
    //2.
    NSMutableArray *marr = [[NSMutableArray alloc]init];
    int a = 1;
    float b = 10.1;
    double c = 10.1321212;
    BOOL is = NO;
    [marr addObject:[NSNumber numberWithInt:a]];
    [marr addObject:[NSNumber numberWithFloat:b]];
    [marr addObject:[NSNumber numberWithDouble:c]];
    [marr addObject:[NSNumber numberWithBool:is]];
    //3.
    BookManager *mana = [[BookManager alloc]init];
    Book *book1 = [Book bookWithName:@"西游记" price:@"10.2"];
    Book *book2 = [Book bookWithName:@"红楼梦" price:@"102"];
    Book *book3 = [Book bookWithName:@"水浒传" price:@"12"];
    [mana addBook:book1];
    [mana addBook:book2];
    [mana addBook:book3];
    [mana showInfo];
    [mana removeBook:book1];
    NSLog(@"111%@",mana.mArr);
    [mana lookForBook:@"水浒传" price:@"100"];
    NSLog(@"%@",book3.price);
    
    return 0;
}
